<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>瀑布流布局</title>
  <style>
    *,
    *::after,
    *::before {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    :root {
      min-height: 100vh;
    }

    :root:focus-within {
      scroll-behavior: smooth;
    }

    body {
      min-height: inherit;
    }
  </style>
</head>

<body>
  <div id="container"></div>
</body>
<script>
  "use strict"; {
    let container = document.getElementById(`container`);
    // 图片的宽度
    let imgWidth = 220;

    function createImgs() {
      for (let i = 0; i <= 40; i++) {
        let src = `img/${i}.jpg`;
        let img = document.createElement("img");
        // 设置图片的位置
        img.addEventListener("load",);
        img.src = src;
        // 添加到容器中
        container.appendChild(img);
      };
    };

    /**  
     * 加载时，就要通过绝对定位设置图片的位置
    */
    function setPos() { };

    /** 
     * 监听窗口的大小变化
    */
    function winResize() {

    };

    window.addEventListener("resize", this.winResize);
  };
</script>

</html>